/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ImageFileSelector;

import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;

/**
 *
 * 
 */
public class ImageFileDialog {
    
    private JFileChooser fc;
    private JFrame jframe;
     
    public  ImageFileDialog(JFrame frame){
        this.jframe=frame;
    }
 
    public File open(){
        // file επιστρέφει το επιλεγμένο αρχείο
        File file =null;
        
        if (fc == null) {
        fc = new JFileChooser();

        //Add a custom file filter and disable the default
        //(Accept All) file filter.
        fc.addChoosableFileFilter(new ImageFilter());
        fc.setAcceptAllFileFilterUsed(false);

        //Add custom icons for file types.
        fc.setFileView(new ImageFileView());

        //Add the preview pane.
        fc.setAccessory(new ImagePreview(fc));
    }

    //Show it.
    int returnVal = fc.showDialog(jframe,
                                    "ΕΠΙΛΕΞΤΕ ΦΩΤΟ ΕΣΤΙΑΤΟΡΙΟΥ");

    //Process the results.
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        file = fc.getSelectedFile();
    } 
    
    //Reset the file chooser for the next time it's shown.
    fc.setSelectedFile(null);
    return file;
} 
}
